<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
<link rel="stylesheet" href="script/bootstrap-3.3.7.min.css">

  <title>拖拽</title>
  <link rel="stylesheet" href="script/jquery-ui.1.10.4.css">  <!-- 注意顺序-->
  <style>
  #draggable {
    width: 100px;
    height: 100px;
    background: #ccc;
  }
  #droppable {
    position: absolute;
    left: 250px;
    top: 0;
    width: 125px;
    height: 125px;
/*    background: #999;
    color: #fff;
    padding: 10px;*/
  }
  </style>
  <script src="script/jquery-1.10.min.js"></script>
  <script src="script/jquery-ui.1.10.4.min.js"></script>
</head>
<body>

<!-- https://www.runoob.com/jqueryui/api-droppable.html -->
<!-- http://www.runoob.com/jqueryui/example-draggable.html -->

<div id="droppable" >请放置到这里！</div>
<div id="draggable" >请拖拽我！</div>
 
<script>
$( "#draggable" ).draggable(); //({ revert: true}) 还原
$( "#droppable" ).droppable({

  // drop: function(event,ui) {
  //   console.log( ui.position.top );
  //   console.log(event)
  // }
});

$( "#droppable" ).droppable( "option", "hoverClass", "btn-info" ); //移动到位置后  添加class 样式


$( "#droppable" ).on( "dropout", function( event, ui ) { //当一个可接受的 draggable 移出 droppable
  console.log("出去")
    console.log(ui.draggable)
    console.log(ui.offset)

} );

$( "#droppable" ).on( "drop", function( event, ui ) { //当一个可接受的 draggable 被放置在 droppable
  console.log("进入")
    console.log(ui.draggable)
    console.log(ui.offset)

} );


$( "#droppable" ).on( "dropdeactivate", function( event, ui ) { //停止拖拽触发，无论停在哪儿
  console.log("停止")
    console.log(ui.helper)
    console.log(ui.offset)

} );

$( "#droppable" ).on( "dropactivate", function( event, ui ) { //开始拖拽触发，无论停在哪儿
  console.log("开始")
    console.log(ui.helper)
    console.log(ui.offset)

} );


</script>
 
</body>
</html>